package 多线程初阶.示例测试;
import java.util.Random;
/**
 * 线程创建演示示例
 */

class MyThread extends Thread{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName());
        Random random = new Random();
        while (true){
            System.out.println(Thread.currentThread().getName());
            try {
                Thread.sleep(random.nextInt(10000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
public class TestDemo1 {
    public static void main(String[] args) throws InterruptedException {
        MyThread t1=new MyThread();
        MyThread t2=new MyThread();
        MyThread t3=new MyThread();
        t1.start();
        t2.start();
        t3.start();
        Random random=new Random();
        while (true){
            System.out.println(Thread.currentThread().getName());
            Thread.sleep(random.nextInt(10000));
        }
    }
}
